package com.example.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Component;

import com.netflix.appinfo.HealthCheckHandler;
import com.netflix.appinfo.InstanceInfo.InstanceStatus;

/**
 * 用于查看健康状态并且及时反映给Eureka
 * @author WUCA3
 *
 */
@Component
public class MyHealthCheckHandler implements HealthCheckHandler {

	@Autowired
	private MyHealthIndicator myHealthIndicator;
	
	@Override
	public InstanceStatus getStatus(InstanceStatus currentStatus) {
		// TODO Auto-generated method stub
		Status status=myHealthIndicator.health().getStatus();
		if(Status.UP.equals(status)){
			return InstanceStatus.UP;
		}else{
			return InstanceStatus.DOWN;
		}
		
	}

}
